/*
 * ReflectStrategy.cpp
 *
 *  Created on: 2010-01-13
 *      Author: adas
 */

#include "ReflectStrategy.h"

bool ReflectStrategy::runStrategy(Element & el_, int populationCount_, double weightFactor_, const std::vector<Element *> &population_,
		const std::vector<Bound> &bounds_, const Element &oldEl_)
{
	calculatePoint(el_,populationCount_,weightFactor_,population_);
	int i = 0;

	while(i < el_.getDimensionCount())
	{
		if(el_.getValueAt(i) < bounds_[i].getMin())
		{
			el_.setValueAt(i, el_.getValueAt(i) + 2*(bounds_[i].getMax() - bounds_[i].getMin()));
		}
		else if(el_.getValueAt(i) > bounds_[i].getMax())
		{
			el_.setValueAt(i, el_.getValueAt(i) - 2*(bounds_[i].getMax() - bounds_[i].getMin()));
		}
		else
			++i;
	}

	return true;
}
